/*
 * opt_params.h
 *
 *  Created on: 30 Oct 2013
 *      Author: Tom Vercauteren
 */

#ifndef OPT_PARAMS_H_
#define OPT_PARAMS_H_

#include <string>
#include <ostream>

struct ClaplanOptimizationMask
{
	unsigned char routine :1;
	unsigned char max_time :1;
	unsigned char tol :1;
	unsigned char rtol :1;
	unsigned char mirw :1;
	unsigned char nskew :1;
	unsigned char disp_quant :1;
	/** unused but set for memory alignement (padding) */
	unsigned char :1;
};

/**
 * Optimization parameters
 */
class ClaplanOptimization
{
private:
	/** Mask to determine which parameters have been set and which haven't. */
	ClaplanOptimizationMask mask;
	std::string routine;
	double max_time, tol, rtol;
	unsigned long mirw, nskew, disp_quant;
public:
	ClaplanOptimization() :
			routine("Powell"), max_time(0), tol(0.001), rtol(0.001), mirw(1), nskew(
					50), disp_quant(0)
	{
		mask.routine = 0;
		mask.max_time = 0;
		mask.tol = 0;
		mask.rtol = 0;
		mask.mirw = 0;
		mask.nskew = 0;
		mask.disp_quant = 0;
	}
	ClaplanOptimization(const ClaplanOptimization &co);
	ClaplanOptimization& operator=(const ClaplanOptimization &co);


	unsigned long getDispQuant() const;
	void setDispQuant(unsigned long dispQuant);
	void unsetDispQuant();
	unsigned char isDispQuantSet() const;

	double getMaxTime() const;
	void setMaxTime(double maxTime);
	void unsetMaxTime();
	unsigned char isMaxTimSet() const;

	unsigned long getMirw() const;
	void setMirw(unsigned long mirw);
	void unsetMirw();
	unsigned char isMirwSet() const;

	unsigned long getNskew() const;
	void setNskew(unsigned long nskew);
	void unsetNskew();
	unsigned char isNskewSet() const;

	const std::string& getRoutine() const;
	void setRoutine(const std::string& routine);
	void unsetRoutine();
	unsigned char isRoutineSet() const;

	double getRtol() const;
	void setRtol(double rtol);
	void unsetRtol();
	unsigned char isRtolSet() const;

	double getTol() const;
	void setTol(double tol);
	void unsetTol();
	unsigned char isTolSet() const;

	friend std::ostream & operator<<(std::ostream & os,
			const ClaplanOptimization &co);
};

#endif /* OPT_PARAMS_H_ */
